from selenium.webdriver.chrome.options import Options as ChromeOption
from selenium.webdriver.firefox.options import Options as FireFoxOption
from selenium.webdriver.edge.options import Options as EdgeOption
from selenium import webdriver

#获取不同浏览器的driver
def getDriver(brower="chrome",timeout=10,isMaximizeWindow=True,isHeadLess=False):
    brower=brower.lower()
    driver=None
    if brower=="chrome":
        chrome_options = ChromeOption()
        if isHeadLess:
            chrome_options.add_argument('--headless')
        driver=webdriver.Chrome(options=chrome_options)
    elif brower=="firfor":
        firefox_options = FireFoxOption()
        if isHeadLess:
            firefox_options.add_argument('--headless')
        driver = webdriver.Firefox(options=firefox_options)
    elif brower=="edge":
        edge_options = EdgeOption()
        if isHeadLess:
            edge_options.add_argument('--headless')
        driver = webdriver.Edge(options=edge_options)
    else:
        driver=None


    if isMaximizeWindow:
        driver.maximize_window()

    driver.implicitly_wait(timeout)

    return driver